<template>
	<view class="container">
		<!-- 头部导航 -->
		<page-navbar :title="foodInfo.name || '美食详情'" backgroundColor="#87CEEB00"></page-navbar>

		<!-- 主要内容区域 -->
		<scroll-view class="content" scroll-y="true" :show-scrollbar="false">
			<!-- 美食图片 -->
			<view class="image-section">
				<image class="food-image" :src="imgUrl + foodInfo.coverId" mode="aspectFill"></image>
				<view class="image-overlay">
					<view class="food-title">{{ foodInfo.name }}</view>
					<view class="food-location" v-if="foodInfo.position">
						<svg-icon name="location" size="16" class="location-icon" />
						<text class="location-text">{{ foodInfo.position?.name }}</text>
					</view>
				</view>
			</view>

			<view class="detail-section">
				<view class="section-header">
					<svg-icon name="restaurant" size="24" class="section-decoration" />
					<text class="section-title">美食简介</text>
				</view>
				<view class="detail-content">
					<text class="detail-text">{{ foodInfo.introTitle }}</text>
				</view>
			</view>

			<!-- 富文本内容 -->
			<view class="content-wrapper">
				<view class="rich-text-container">
					<rich-text class="rich-text" :nodes="foodInfo.intro"></rich-text>
				</view>
			</view>

			<!-- <view class="detail-section">
				<view class="section-header">
					<svg-icon name="restaurant" size="24" class="section-decoration" />
					<text class="section-title">美食介绍</text>
				</view>
				<view class="detail-content">
					<text class="detail-text">{{ foodInfo.description }}</text>
				</view>
			</view>
			<view class="highlight-section">
				<view class="section-header">
					<svg-icon name="star" size="24" class="section-decoration" />
					<text class="section-title">特色亮点</text>
				</view>
				<view class="highlight-list">
					<view class="highlight-item" v-for="(item, index) in highlights" :key="index">
						<view class="highlight-icon">{{ item.icon }}</view>
						<view class="highlight-content">
							<view class="highlight-name">{{ item.name }}</view>
							<view class="highlight-desc">{{ item.description }}</view>
						</view>
					</view>
				</view>
			</view> -->

			<!-- 推荐信息 -->
			<view class="recommend-section" v-if="foodInfo.position">
				<view class="section-header">
					<view class="section-decoration">🏪</view>
					<text class="section-title">推荐地点</text>
				</view>
				<view class="recommend-card">
					<view class="recommend-content">
						<view class="recommend-name">{{ foodInfo.position?.name }}</view>
						<view class="recommend-desc">景区内品尝{{ foodInfo.name }}的推荐地点</view>
						<view class="recommend-tips">
							<text class="tip-item">🕐 营业时间：09:00-21:00</text>
						</view>
					</view>
					<button class="navigate-btn" @click="navigateToLocation">导航</button>
				</view>
			</view>

			<!-- 温馨提示 -->
			<view class="tips-section">
				<view class="section-header">
					<svg-icon name="lightbulb" size="32" />
					<text class="section-title">温馨提示</text>
				</view>
				<view class="tips-content">
					<view class="tip-item">
						<svg-icon name="sparkle" size="16" class="tip-icon" />
						<text class="tip-text">建议游览景区时品尝，体验更佳</text>
					</view>
					<view class="tip-item">
						<svg-icon name="leaf" size="16" class="tip-icon" />
						<text class="tip-text">选用景区当地新鲜食材制作</text>
					</view>
					<view class="tip-item">
						<svg-icon name="camera" size="16" class="tip-icon" />
						<text class="tip-text">精美造型，适合拍照留念</text>
					</view>
				</view>
			</view>

			<!-- 底部占位 -->
			<view class="bottom-placeholder"></view>
		</scroll-view>
	</view>
</template>

<script setup>
import { ref, reactive, onMounted, watch, computed, nextTick, toRefs } from 'vue';
import { onLoad, onShow, onShareAppMessage } from '@dcloudio/uni-app';
import common from '@/utils/common.js';
import api from '@/api/index.js';

import useUserInfoStore from '@/stores/user';
import { storeToRefs } from 'pinia';

const userInfoStore = useUserInfoStore();
const { userData } = toRefs(userInfoStore);

const imgUrl = uni.imgUrl;

// 美食信息
const foodInfo = ref({});


onLoad((options) => {
	if (options.id) {
		getData(options.id);
	}
});

onMounted(() => { });

const getData = (id) => {
	api.attractionsApi.detailSpot({ id }).then((res) => {
		console.log('美食详情', res);
		foodInfo.value = res
	}).catch((error) => {
		console.error('获取美食列表失败:', error);
	});
};

// 导航到推荐地点
const navigateToLocation = () => {
	common.openMapNavigation(foodInfo.value.position.latitude, foodInfo.value.position.longitude, foodInfo.value.position.name);
};

</script>

<style lang="scss" scoped>
.container {
	background: linear-gradient(180deg, #87CEEB 0%, #F0F8FF 50%, #ffffff 100%);
	height: 100vh;
	width: 100%;
	position: relative;
	overflow: hidden;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
}

.content {
	flex: 1;
	overflow: hidden;
	box-sizing: border-box;
	position: relative;
	z-index: 1;
}

/* 美食图片区域 */
.image-section {
	position: relative;
	height: 500rpx;
	margin: 0 30rpx 30rpx 30rpx;
	border-radius: 20rpx;
	overflow: hidden;
	box-shadow: 0 8rpx 32rpx rgba(135, 206, 235, 0.2);

	.food-image {
		width: 100%;
		height: 100%;
	}

	.image-overlay {
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
		padding: 60rpx 30rpx 30rpx;
		color: white;

		.food-title {
			font-size: 40rpx;
			font-weight: bold;
			margin-bottom: 15rpx;
		}

		.food-location {
			display: flex;
			align-items: center;
			gap: 8rpx;

			.location-icon {
				font-size: 24rpx;
			}

			.location-text {
				font-size: 26rpx;
				opacity: 0.9;
			}
		}
	}
}

.content-wrapper {
	margin-top: 20rpx;
	padding: 40rpx;
	box-sizing: border-box;

	.rich-text-container {
		.rich-text {
			line-height: 1.8;
			color: #333;
			font-size: 28rpx;
		}
	}
}

/* 通用区域样式 */
.detail-section,
.highlight-section,
.recommend-section,
.tips-section {
	margin: 0 30rpx 30rpx 30rpx;

	.section-header {
		display: flex;
		align-items: center;
		gap: 15rpx;
		margin-bottom: 20rpx;

		.section-title {
			font-size: 32rpx;
			font-weight: bold;
			color: #2E7D32;
		}

		.section-decoration {
			font-size: 28rpx;
			opacity: 0.7;
		}
	}
}

/* 美食详情 */
.detail-content {
	background: rgba(255, 255, 255, 0.95);
	border-radius: 20rpx;
	padding: 30rpx;
	box-shadow: 0 4rpx 20rpx rgba(135, 206, 235, 0.1);

	.detail-text {
		font-size: 28rpx;
		color: #333;
		line-height: 1.8;
	}
}

/* 特色亮点 */
.highlight-list {
	.highlight-item {
		background: rgba(255, 255, 255, 0.95);
		border-radius: 20rpx;
		padding: 25rpx;
		margin-bottom: 15rpx;
		display: flex;
		align-items: center;
		box-shadow: 0 4rpx 20rpx rgba(135, 206, 235, 0.1);

		.highlight-icon {
			font-size: 40rpx;
			margin-right: 20rpx;
			flex-shrink: 0;
		}

		.highlight-content {
			flex: 1;

			.highlight-name {
				font-size: 28rpx;
				font-weight: bold;
				color: #2E7D32;
				margin-bottom: 8rpx;
			}

			.highlight-desc {
				font-size: 24rpx;
				color: #666;
				line-height: 1.4;
			}
		}
	}
}

/* 推荐地点 */
.recommend-card {
	background: rgba(255, 255, 255, 0.95);
	border-radius: 20rpx;
	padding: 30rpx;
	display: flex;
	align-items: center;
	box-shadow: 0 4rpx 20rpx rgba(135, 206, 235, 0.1);

	.recommend-content {
		flex: 1;

		.recommend-name {
			font-size: 30rpx;
			font-weight: bold;
			color: #2E7D32;
			margin-bottom: 10rpx;
		}

		.recommend-desc {
			font-size: 24rpx;
			color: #666;
			margin-bottom: 15rpx;
		}

		.recommend-tips {
			display: flex;
			flex-direction: column;
			gap: 8rpx;

			.tip-item {
				font-size: 22rpx;
				color: #4CAF50;
			}
		}
	}

	.navigate-btn {
		background: linear-gradient(135deg, #4CAF50, #66BB6A);
		color: white;
		border: none;
		border-radius: 30rpx;
		padding: 20rpx 30rpx;
		font-size: 24rpx;
		font-weight: bold;
		box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.3);

		&::after {
			border: none;
		}

		&:active {
			transform: scale(0.95);
		}
	}
}

/* 温馨提示 */
.tips-content {
	background: rgba(255, 255, 255, 0.95);
	border-radius: 20rpx;
	padding: 30rpx;
	box-shadow: 0 4rpx 20rpx rgba(135, 206, 235, 0.1);

	.tip-item {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
		gap: 15rpx;

		&:last-child {
			margin-bottom: 0;
		}

		.tip-icon {
			font-size: 24rpx;
			flex-shrink: 0;
		}

		.tip-text {
			font-size: 24rpx;
			color: #666;
			line-height: 1.4;
		}
	}
}

.bottom-placeholder {
	height: 100rpx;
}
</style>
